<?php

declare(strict_types=1);

namespace App\Model;

// use Hyperf\DbConnection\Model\Model;

/**
 * @property int $id
 * @property string $username
 * @property string $request_url
 * @property string $type
 * @property string $operation_name
 * @property string $ip
 * @property string $source
 * @property int $spend_time
 * @property \Carbon\Carbon $update_time
 * @property \Carbon\Carbon $create_time
 * @property string $params_json
 * @property string $class_path
 * @property string $method_name
 */
class OperateLog extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'operate_log';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = [];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'spend_time' => 'integer'];

    // 如果你需要隐藏原始的 create_time 字段
    protected array $hidden = ['create_time', 'update_time','request_url','spend_time','operation_name','params_json','class_path','method_name'];

    // 如果你需要显示新的 createTime 字段
    protected array $appends = ['createTime', 'updateTime', 'requestUrl','spendTime', 'operationName', 'paramsJson', 'classPath', 'methodName'];

    public function getCreateTimeAttribute()
    {
        return $this->attributes['create_time'];
    }

    public function getUpdateTimeAttribute()
    {
        return $this->attributes['update_time'];
    }
    public function getRequestUrlAttribute()
    {
        return $this->attributes['request_url'];
    }
    public function getSpendTimeAttribute()
    {
        return $this->attributes['spend_time'];
    }
    public function getOperationNameAttribute()
    {
        return $this->attributes['operation_name'];
    }
    public function getParamsJsonAttribute()
    {
        return $this->attributes['params_json'];
    }
    public function getClassPathAttribute()
    {
        return $this->attributes['class_path'];
    }
    public function getMethodNameAttribute()
    {
        return $this->attributes['method_name'];
    }

}
